package com.woniuxy.springbootrabbit.kill;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class KillDeadConsumer {
    // 接收生产者发送的消息
    @RabbitListener(queues = "kill_dead_queue")  // 监听消息队列
    public void accept(String msg, Channel channel, Message message) throws IOException {
        System.out.println("死信消费者接收到:" + msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
